home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 7: Sunsite / Linux Cubed Series 7 - Sunsite Vol 1.iso / system / shells / scsh-0.4 / scsh-0 / scsh-0.4.2 / debug / link-debug.scm < prev    next >
Text File  |  1995-10-13  |  1KB  |  37 lines

  1. ; Copyright (c) 1993, 1994 Richard Kelsey and Jonathan Rees.  See file COPYING.
  2.  
  3.  
  4.  
  5.  
  6. ; Stuff for debugging new images:
  7.  
  8. (define (ev form package)
  9.   (invoke-template (compile-form form package)
  10.            (package-uid package)))
  11.  
  12. ; If desired, this definition of invoke-template can be replaced by
  13. ; something that starts up a different virtual machine.
  14.  
  15. (define (invoke-template template env . args)
  16.   (apply (make-closure template env)
  17.      args))
  18.  
  19. ; Utility for tracking down uses of variables
  20.  
  21. (define (who-uses name proc)
  22.   (let recur ((tem (closure-template proc))
  23.               (path '()))
  24.     (let loop ((i 0))
  25.       (if (< i (template-length tem))
  26.           (let ((thing (template-ref tem i))
  27.                 (down (lambda (tem)
  28.                         (recur tem (cons (or (template-ref tem 1) i) path)))))
  29.             (cond ((template? thing)
  30.                    (down thing))
  31.                   ((location? thing)
  32.                    (if (eq? (location-name thing) name)
  33.                        (begin (write path) (newline))))
  34.                   ((closure? thing)
  35.                    (down (closure-template thing))))
  36.             (loop (+ i 1)))))))
  37.